package com.puzzlebazar.server;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Text;
import com.puzzlebazar.client.admin.SiteInfo;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class SiteInfoJdo {

	@NotPersistent
	public static final transient String UniqueId = "Unique";

	@SuppressWarnings("unused")
	@PrimaryKey
    private String id = UniqueId;

    @Persistent
	private String siteName = "";
    @Persistent
	private String siteDescription = "";
    @Persistent
	private Text welcomeMessage = new Text("");
    
    /**
     * @param destination The SiteInfo object to populate with this object content
     */
    public void to( SiteInfo destination ) {
    	destination.setSiteName(siteName);
    	destination.setSiteDescription(siteDescription);
    	destination.setWelcomeMessage(welcomeMessage.getValue());
    }

    /**
     * @param source The SiteInfo object from which to create this object
     */
    public void from( SiteInfo source ) {
    	siteName = source.getSiteName();
    	siteDescription = source.getSiteDescription();
    	welcomeMessage = new Text(source.getWelcomeMessage());
    }
	
}
